home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
quartz
/
q1082.dms
/
q1082.adf
/
src.lzh
/
Fig
/
Zoom.c
< prev
Wrap
C/C++ Source or Header
|
1991-07-18
|
4KB
|
159 lines
#define ZOOMWIDTH 40
#define ZOOMHEIGHT 40
extern struct ExecBase *SysBase;
extern struct Screen *Screen;
struct Window *ZoomWindow;
struct BitMap ZoomSrcBitMap,ZoomDstBitMap;
struct RastPort ZoomSrcRPort;
struct BitScaleArgs ScaleArgs;
SHORT ZoomToX,ZoomToY;
struct NewWindow NewZoomWindow =
{
0,12,
100,100,
0,1,
CLOSEWINDOW | NEWSIZE,
RMBTRAP | WINDOWSIZING | WINDOWDRAG | WINDOWCLOSE,
(struct Gadget *)NULL,
(struct Image *)NULL,
(STRPTR)"Fig Zoom Window",
(struct Screen *)NULL,
(struct BitMap *)NULL,
50,50,
~0,~0,
CUSTOMSCREEN
};
VOID
DeleteZoomBitMap()
{
if(ZoomSrcBitMap . Planes[0])
{
FreeMem(ZoomSrcBitMap . Planes[0],ZoomSrcBitMap . BytesPerRow * ZoomSrcBitMap . Rows);
ZoomSrcBitMap . Planes[0] = NULL;
}
if(ZoomDstBitMap . Planes[0])
{
FreeMem(ZoomDstBitMap . Planes[0],ZoomDstBitMap . BytesPerRow * ZoomDstBitMap . Rows);
ZoomDstBitMap . Planes[0] = NULL;
}
}
BYTE
CreateZoomBitMap()
{
SHORT ScaleX,ScaleY;
ZoomToX = ZoomWindow -> Width - (ZoomWindow -> BorderLeft + ZoomWindow -> BorderRight);
ZoomToY = ZoomWindow -> Height - (ZoomWindow -> BorderTop + ZoomWindow -> BorderBottom);
ScaleArgs . bsa_SrcWidth = ZOOMWIDTH;
ScaleArgs . bsa_SrcHeight = ZOOMHEIGHT;
ScaleArgs . bsa_XSrcFactor = 1;
ScaleArgs . bsa_YSrcFactor = 1;
ScaleArgs . bsa_XDestFactor = (ZoomToX + ZOOMWIDTH - 1) / ZOOMWIDTH;
ScaleArgs . bsa_YDestFactor = (ZoomToY + ZOOMHEIGHT - 1) / ZOOMHEIGHT;
ScaleArgs . bsa_SrcBitMap = &ZoomSrcBitMap;
ScaleArgs . bsa_DestBitMap = &ZoomDstBitMap;
SetDrMd(ZoomWindow -> RPort,JAM2);
SetAPen(ZoomWindow -> RPort,0);
RectFill(ZoomWindow -> RPort,ZoomWindow -> BorderLeft,ZoomWindow -> BorderTop,ZoomWindow -> BorderLeft + ZoomToX - 1,ZoomWindow -> BorderTop + ZoomToY - 1);
SetDrMd(ZoomWindow -> RPort,COMPLEMENT);
SetAPen(ZoomWindow -> RPort,1);
ScaleX = ScalerDiv(ZOOMWIDTH,ScaleArgs . bsa_XDestFactor,ScaleArgs . bsa_XSrcFactor);
ScaleY = ScalerDiv(ZOOMHEIGHT,ScaleArgs . bsa_YDestFactor,ScaleArgs . bsa_YSrcFactor);
InitBitMap(&ZoomSrcBitMap,1,ZOOMWIDTH,ZOOMHEIGHT);
InitBitMap(&ZoomDstBitMap,1,ScaleX,ScaleY);
InitRastPort(&ZoomSrcRPort);
if(ZoomSrcBitMap . Planes[0] = (PLANEPTR)AllocMem(ZoomSrcBitMap . BytesPerRow * ZoomSrcBitMap . Rows,MEMF_CHIP|MEMF_CLEAR))
{
ZoomSrcRPort . BitMap = &ZoomSrcBitMap;
if(ZoomDstBitMap . Planes[0] = (PLANEPTR)AllocMem(ZoomDstBitMap . BytesPerRow * ZoomDstBitMap . Rows,MEMF_CHIP|MEMF_CLEAR))
return(TRUE);
}
DeleteZoomBitMap();
return(FALSE);
}
VOID
CloseZoomWindow()
{
DeleteZoomBitMap();
if(ZoomWindow)
{
NewZoomWindow . LeftEdge = ZoomWindow -> LeftEdge;
NewZoomWindow . TopEdge = ZoomWindow -> TopEdge;
NewZoomWindow . Width = ZoomWindow -> Width;
NewZoomWindow . Height = ZoomWindow -> Height;
CloseWindow(ZoomWindow);
ZoomWindow = NULL;
}
}
BYTE
OpenZoomWindow()
{
WORD Dims[4];
NewZoomWindow . Screen = Screen;
Dims[0] = NewZoomWindow . LeftEdge;
Dims[1] = NewZoomWindow . TopEdge;
Dims[2] = NewZoomWindow . Width;
Dims[3] = NewZoomWindow . Height;
if(ZoomWindow = (struct Window *)OpenWindowTags(&NewZoomWindow,
WA_Zoom,&Dims[0],
TAG_DONE))
{
if(CreateZoomBitMap())
return(TRUE);
CloseWindow(ZoomWindow);
DisplayBeep(Screen);
}
return(FALSE);
}
VOID
ZoomToWindow(struct RastPort *RPort,SHORT X,SHORT Y,SHORT OffsetX,SHORT OffsetY)
{
ClipBlit(RPort,X,Y,&ZoomSrcRPort,0,0,ZOOMWIDTH,ZOOMHEIGHT,0xC0);
BitMapScale(&ScaleArgs);
BltBitMapRastPort(&ZoomDstBitMap,0,0,ZoomWindow -> RPort,ZoomWindow -> BorderLeft,ZoomWindow -> BorderTop,ZoomToX,ZoomToY,0xC0);
OffsetX = OffsetX * ScaleArgs . bsa_XDestFactor;
OffsetY = OffsetY * ScaleArgs . bsa_YDestFactor;
Move(ZoomWindow -> RPort,ZoomWindow -> BorderLeft + OffsetX,ZoomWindow -> BorderTop);
Draw(ZoomWindow -> RPort,ZoomWindow -> BorderLeft + OffsetX,ZoomWindow -> BorderTop + ZoomToY - 1);
Move(ZoomWindow -> RPort,ZoomWindow -> BorderLeft,ZoomWindow -> BorderTop + OffsetY);
Draw(ZoomWindow -> RPort,ZoomWindow -> BorderLeft + ZoomToX - 1,ZoomWindow -> BorderTop + OffsetY);
}